package com.ruoyi.workYear.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.workYear.domain.IfmWorkYear;
import com.ruoyi.workYear.service.IIfmWorkYearService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 工作年限Controller
 * 
 * @author ruoyi
 * @date 2024-11-01
 */
@RestController
@RequestMapping("/workYear/ifmWorkYear")
public class IfmWorkYearController extends BaseController
{
    @Autowired
    private IIfmWorkYearService ifmWorkYearService;

    /**
     * 查询工作年限列表
     */
    @PreAuthorize("@ss.hasPermi('workYear:ifmWorkYear:list')")
    @GetMapping("/list")
    public TableDataInfo list(IfmWorkYear ifmWorkYear)
    {
        startPage();
        List<IfmWorkYear> list = ifmWorkYearService.selectIfmWorkYearList(ifmWorkYear);
        return getDataTable(list);
    }

    /**
     * 导出工作年限列表
     */
    @PreAuthorize("@ss.hasPermi('workYear:ifmWorkYear:export')")
    @Log(title = "工作年限", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, IfmWorkYear ifmWorkYear)
    {
        List<IfmWorkYear> list = ifmWorkYearService.selectIfmWorkYearList(ifmWorkYear);
        ExcelUtil<IfmWorkYear> util = new ExcelUtil<IfmWorkYear>(IfmWorkYear.class);
        util.exportExcel(response, list, "工作年限数据");
    }

    /**
     * 获取工作年限详细信息
     */
    @PreAuthorize("@ss.hasPermi('workYear:ifmWorkYear:query')")
    @GetMapping(value = "/{workId}")
    public AjaxResult getInfo(@PathVariable("workId") Long workId)
    {
        return success(ifmWorkYearService.selectIfmWorkYearByWorkId(workId));
    }

    /**
     * 新增工作年限
     */
    @PreAuthorize("@ss.hasPermi('workYear:ifmWorkYear:add')")
    @Log(title = "工作年限", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody IfmWorkYear ifmWorkYear)
    {
        return toAjax(ifmWorkYearService.insertIfmWorkYear(ifmWorkYear));
    }

    /**
     * 修改工作年限
     */
    @PreAuthorize("@ss.hasPermi('workYear:ifmWorkYear:edit')")
    @Log(title = "工作年限", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody IfmWorkYear ifmWorkYear)
    {
        return toAjax(ifmWorkYearService.updateIfmWorkYear(ifmWorkYear));
    }

    /**
     * 删除工作年限
     */
    @PreAuthorize("@ss.hasPermi('workYear:ifmWorkYear:remove')")
    @Log(title = "工作年限", businessType = BusinessType.DELETE)
	@DeleteMapping("/{workIds}")
    public AjaxResult remove(@PathVariable Long[] workIds)
    {
        return toAjax(ifmWorkYearService.deleteIfmWorkYearByWorkIds(workIds));
    }
}
